<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<button @click="topay()">{{title}}</button>
		</view>
	</view>
</template>

<script>
	
	
	 import websocket from '@/js/websocket-uni.js';
	 
	 
	
	 
	export default {
		data() {
			return {
				title: 'Hello',
				
			}
		},
		onLoad() {
               
		},
		methods: {
            topay:function(){
			            var token = "admin2";
						var url = 'ws://192.168.3.83:8080/app?token='+token
						
						function subscribe(client)
						{
							client.subscribe('/topic/subscribeTest', function(e){
																				   console.log('群聊')
																				   console.log(e);
																				   
																				});
																				
						    client.subscribe('/user/queue/test', function(e){
						    																								   console.log('单聊')
						    																								   console.log(e);
						    });
						}
						
						
						
						websocket.init(url).then(client => {
						             //执行订阅函数
									 websocket.execSubscrip(subscribe);
								
						 });    
			    
			           
			 }
		}    
		
		
		
	}
	
	
	
	
	   


</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
